package Thread.BlockingQueue;

public class Demo35 {
    //这个例子解释了interrupt在终止进程之前会先唤醒进程
    //当线程在synchronized块内调用wait()方法进入等待状态时，如果该线程被中断，会从等待状态中唤醒并抛出中断异常。
    public static Object locker=new Object();
    public static void main(String[] args) throws InterruptedException {
        Thread t=new Thread(()->{
            synchronized (locker){
                System.out.println("wait前");
                try {
                    locker.wait();
                } catch (InterruptedException e) {
                    System.out.println("wait后");
                    throw new RuntimeException(e);
                }
            }
        });
        t.start();
        Thread.sleep(1000);
        t.interrupt();
    }
}
